﻿using BBICMS.Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace BBICMS.WebUI.ViewModels
{
    public class CategoriesListViewModel 
    {
        public IList<Category> Categories { get; set; }

        public string CategoriesJSON
        {
            get
            {
                JsonSerializerSettings settings =
                    new JsonSerializerSettings()
                    {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                    };

                settings.ContractResolver =
                    new CamelCasePropertyNamesContractResolver();

                var categories = JsonConvert.SerializeObject(this.Categories, settings);
                return categories;
            }
        }

    }
}